
class LoginController
{
	def userRoleDaoImpl;
	
	def index = {}
	
	def doLogin=
	{
		def username = params.username;
		def password = params.password;
		def user = Userinfo.find("from Userinfo where username='${username}' and password='${password}'");
		if(user)
		{
			def userRole = Roleinfo.executeQuery("select menus from Roleinfo where id=(select roleinfo.id from Userinfo where id=${user.id})");		
			def roleList = userRoleDaoImpl.getUserRole(userRole[0]);
			session.menu1 = roleList[0];
			session.m2Map = roleList[1];
			session.m3Map = roleList[2];
			session.userId = user.id;
			session.username = user.username;
			session.realname = user.realname;
			session.setMaxInactiveInterval(3600)
			redirect(controller:"frame", action:"totalPage")	
		}else
		{
			render(view:'index', model:[flag:'error']);
		}
	}
	

	def sessionInvalid = 
	{
		//redirect(uri:"/index.gsp")
	}

	def sessionInvalidPage = {}

}